@extends('admin.home.main')
@section('body')
    <section id="main-content">
        <section class="wrapper">
            <h3>测试报告列表</h3>
            <hr>
            <a href="/admin/test_report/add" class="btn btn-success">添加报告</a>
            <!-- row -->
            <div class="row mt">
                <div class="col-md-12">
                    <div class="content-panel">
                        <table class="table table-striped table-advance table-hover">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>报告名称</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($report_list as $rst)
                                <tr>
                                    <td>{{$rst->id}}</td>
                                    <td>{{$rst->name}}</td>
                                    <td>{{$rst->add_date}}</td>
                                    <td>
                                        <a href="/admin/test_report/edit/{{$rst->id}}" class="btn btn-primary
                                        btn-xs">编辑</a>
                                        <button type="button" colid="{{$rst->id}}" class="btn btn-danger btn-xs col_del">删除</button>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- /col-md-12 -->
            </div>
            <!-- /row -->
        </section>
    </section>
    <script type="text/javascript">
        $('.col_del').click(function(){
            var _colId = $(this).attr('colid');

            var a = confirm('请确认是否要删除该报告');
            var t = $(this).parent().parent();

            if(a == true){
                $.ajax({
                    'type':'get',
                    'url':'/admin/test_report/del/'+_colId,
                    'dataType':'json',
                    success:function(msg){
                        if(msg.code == 200){
                            alert('删除成功');
                        }else{
                            alert('删除失败');
                        }
                        location.reload();
                    }
                })
            }
        })
    </script>
@endsection